<div id="home">
<div id="recent">
    <h2>What is going on now?</h2>
    <div id="recent-actions">
        <?php
        $vars = array("%aid%", "%sport%", "%competition%", "%id%", "%participants%", "%actions%");
        $varsact = array("%part%", "%min%", "%action%", "%participant%");
        foreach ($this->events as $event) {
            $actions = "";
            if ($event->lastindex>-1 && $event->last["a"]>-1) {
                $valuesact = array($event->part, $event->time, ($event->sport["actions"]["action_".$event->last["a"]]["name"]),
                            $event->participants[$event->last["p"]]['n']);
                $actions = str_replace($varsact, $valuesact, $this->actiontemplate);
            }
            $values = array($event->id.$event->lastindex, $event->sport["_id"], $event->competition, $event->id,
                        "{$event->participants[0]['s']} - {$event->participants[0]['n']} vs. {$event->participants[1]['n']} - {$event->participants[1]['s']}",
                          $actions);
            echo str_replace($vars, $values, $this->matchtemplate);
        }
        ?>
    </div>
</div>
<div id="user">
    <? if ($this->isAuth):?>
    <div id="useraction"><a id="createEvent" href="/event/create">Create a new event</a></div>
    <? else: ?>
    <h2>Join Escoreboar!</h2>
     <?php
    if (isset ( $this->error )) :
        ?>
    <div class="error"><?=$this->error ;?></div>
    <?php endif;?>
    <?=$this->joinform;?>
    <?endif;?>
</div>
</div>